<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8" />
    <title>Document</title>
    <style></style>
  </head>
  <body>
    <div>闭包案例</div>
    <script>
      //案例一
      function makePower(power) {
        return function (number) {
          return Math.pow(number, power);
        };
      }

      let power2 = makePower(2);
      let power3 = makePower(3);

      console.log(power2(4));
      console.log(power2(5));
      console.log(power3(4));

      //案例二
      function makeSalary(base) {
        return function (perFormance) {
          return base + perFormance;
        };
      }

      let salaryLeve1 = makeSalary(12000);
      let salaryLeve2 = makeSalary(15000);

      console.log(salaryLeve1(2000));
      console.log(salaryLeve2(3000));
    </script>
  </body>
</html>
